﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        private int windowWidth = 0;
        private int windowHeight = 0;
        private int widthPadding = 200;
        private int heightPadding = 200;
        private int widthGutter = 10;
        private int heightGutter = 10;
        private int[] ladderWidth = new int[3];
        private int[] ladderHeight = new int[3];
        private int baseHeight = 50;

        public Form1()
        {
            InitializeComponent();
            this.FormBorderStyle = FormBorderStyle.None;     //设置窗体为无边框样式
            this.WindowState = FormWindowState.Maximized;    //最大化窗体 

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.countSize();
            //控制球
            Form2 topForm = new Form2();
            topForm.Text = "浮动按钮";
            topForm.TopMost = true;
            topForm.TopLevel = true;
            topForm.SetAssociateWindow(this);
            topForm.Show();

            pictureBox1.Parent = bgPanel;
            pictureBox1.BackColor = Color.Transparent;
            timer1.Start();
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {

            
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void pictureBox1_Click_1(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start("http://www.baidu.com");
        }

        private void pictureBox3_Click(object sender, EventArgs e)
        {

        }
        private void countSize() {
            //计算每个模块的大小和位置 
            this.windowWidth = this.Width;
            this.windowHeight = this.Height;

            this.ladderWidth[0] = this.windowWidth - this.widthPadding - this.widthGutter;
            this.ladderWidth[1] = (this.windowWidth - this.widthPadding) / 2 - this.widthGutter;
            this.ladderWidth[2] = (this.windowWidth - this.widthPadding) / 4 - this.widthGutter;
            this.ladderHeight[0] = this.windowHeight - this.heightPadding - this.heightGutter;
            this.ladderHeight[1] = (this.windowHeight - this.heightPadding) / 2 - this.heightGutter;
            this.ladderHeight[2] = (this.windowHeight - this.heightPadding) / 4 - this.heightGutter;

            //背景大小
            bgPanel.Width = this.Width;
            bgPanel.Height = this.Height;

            //logo 大小
            //self.bitmap_button = BitmapButton(self, bitmap = logo, size = (500, 100), pos = (self.width_padding / 2, self.height_padding / 2 - 100 + self.base_height))
            logoPic.Width = 500;
            logoPic.Height = 100;
            Point logoPoint = new Point();
            logoPoint.X = this.widthPadding / 2 ;
            logoPoint.Y = this.heightPadding / 2 - 100 + this.baseHeight;
            logoPic.Location = logoPoint;


            //时间位置
            //177, 38
            
            
            Point lbTimePoint = new Point();
            lbTimePoint.X = this.widthPadding / 2 + this.ladderWidth[0] - lbTime.Width;
            lbTimePoint.Y = this.heightPadding / 2 - 100 + this.baseHeight;
            lbTime.Location = lbTimePoint;

            //第一块
            pictureBox1.Width = this.ladderWidth[1];
            pictureBox1.Height = this.ladderHeight[1];
            Point p = pictureBox1.Location;
            p.X = this.widthPadding / 2;
            p.Y = this.baseHeight + this.heightPadding / 2;
            pictureBox1.Location = p;


            //第二块
            pictureBox2.Width = this.ladderWidth[2];
            pictureBox2.Height = this.ladderHeight[1];
            Point p2 = pictureBox2.Location;
            p2.X = this.widthPadding / 2 + this.ladderWidth[1] + this.widthGutter;
            p2.Y = this.baseHeight + this.heightPadding / 2;
            pictureBox2.Location = p2;


            //第三块
            pictureBox3.Width = this.ladderWidth[2];
            pictureBox3.Height = this.ladderHeight[1];
            Point p3 = pictureBox3.Location;
            p3.X = this.widthPadding / 2 + this.ladderWidth[1] + this.ladderWidth[2] + this.widthGutter * 2;
            p3.Y = this.baseHeight + this.heightPadding / 2;
            pictureBox3.Location = p3;

            //第四块
            pictureBox4.Width = this.ladderWidth[2];
            pictureBox4.Height = this.ladderHeight[1];
            Point p4 = pictureBox4.Location;
            p4.X = this.widthPadding / 2;
            p4.Y = this.baseHeight + this.heightPadding / 2 + this.ladderHeight[1] + this.heightGutter;
            pictureBox4.Location = p4;

            //第五块
            pictureBox5.Width = this.ladderWidth[2];
            pictureBox5.Height = this.ladderHeight[1];
            Point p5 = pictureBox5.Location;
            p5.X = this.widthPadding / 2 + this.ladderWidth[2] + this.widthGutter;
            p5.Y = this.baseHeight + this.heightPadding / 2 + this.ladderHeight[1] + this.heightGutter;
            pictureBox5.Location = p5;

            //第六块
            pictureBox6.Width = this.ladderWidth[2];
            pictureBox6.Height = this.ladderHeight[2];
            Point p6 = pictureBox6.Location;
            p6.X = this.widthPadding / 2 + this.ladderWidth[1] + this.widthGutter;
            p6.Y = this.baseHeight + this.heightPadding / 2 + this.ladderHeight[1] + this.heightGutter;
            pictureBox6.Location = p6;

            //第七块
            pictureBox7.Width = this.ladderWidth[2];
            pictureBox7.Height = this.ladderHeight[2];
            Point p7 = pictureBox5.Location;
            p7.X = this.widthPadding / 2 + this.ladderWidth[1] + this.ladderWidth[2] + this.widthGutter * 2;
            p7.Y = this.baseHeight + this.heightPadding / 2 + this.ladderHeight[1] + this.heightGutter;
            pictureBox7.Location = p7;

            //第八块
            pictureBox8.Width = this.ladderWidth[2];
            pictureBox8.Height = this.ladderHeight[2];
            Point p8 = pictureBox8.Location;
            p8.X = this.widthPadding / 2 + this.ladderWidth[1] + this.widthGutter;
            p8.Y = this.baseHeight + this.heightPadding / 2 + this.ladderHeight[1] + this.ladderHeight[2] + this.heightGutter * 2;
            pictureBox8.Location = p8;

            //第九块
            pictureBox9.Width = this.ladderWidth[2];
            pictureBox9.Height = this.ladderHeight[2];
            Point p9 = pictureBox5.Location;
            p9.X = this.widthPadding / 2 + this.ladderWidth[2] * 3 + this.widthGutter * 3;
            p9.Y = this.baseHeight + this.heightPadding / 2 + this.ladderHeight[1] + this.ladderHeight[2] + this.heightGutter * 2;
            pictureBox9.Location = p9;

        }
        private void Form1_SizeChanged(object sender, EventArgs e)
        {
            this.countSize();
 
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            lbTime.Text = DateTime.Now.ToLongTimeString().ToString();
        }
    }
}
